/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.cuni.amis.pogamut.episodic.lispbots;

import org.apache.commons.cli.*;

/**
 *
 * @author rain
 */
public class CliArgs {
    // The file we want to parse and feed to memory.
    public static String eventtree = "testdata365.lisp";
    public static String descriptor = "testdata.desc";
    public static String memin = "";
    public static String memout = "";

    public static boolean visualise = false;

    public static int time = 0;

    public static int timeLimit = 99999999;

    public static int experiment = 1;

    public static void parseOpts(String[] args) {
        final CommandLineParser cmdLineGnuParser = new GnuParser();
        final Options gnuOptions = new Options();
        gnuOptions.addOption("x", "experiment", true, "The experiment number to run");
        gnuOptions.addOption("e", "eventtree", true, "The lisp generated output");
        gnuOptions.addOption("d", "descriptor", true, "The descriptor to lisp output");
        gnuOptions.addOption("i", "memin", true, "Use this serialized memory ball");
        gnuOptions.addOption("o", "memout", true, "Save serialized memory ball");
        gnuOptions.addOption("v", "visualise", false, "Run the visualiser");
        gnuOptions.addOption("t", "timelimit", true, "Force stop the simulation after this many days have passed");

        CommandLine commandLine;
        try {
            commandLine = cmdLineGnuParser.parse(gnuOptions, args);
            if ( commandLine.hasOption("x") ) {
                experiment = Integer.decode(commandLine.getOptionValue("x"));
            }
            if ( commandLine.hasOption("t") ) {
                timeLimit = Integer.decode(commandLine.getOptionValue("t"));
            }
            if ( commandLine.hasOption("e") ) {
                eventtree = commandLine.getOptionValue("e");
            }
            if ( commandLine.hasOption("d") ) {
                descriptor = commandLine.getOptionValue("d");
            }
            if ( commandLine.hasOption("i") ) {
                memin = commandLine.getOptionValue("i");
            }
            if ( commandLine.hasOption("o") ) {
            memout = commandLine.getOptionValue("o");
            }
            if ( commandLine.hasOption("v") ) {
                visualise = true;
            }
        }
        catch (ParseException parseException) { // checked exception
            System.err.println("Encountered exception while parsing using GnuParser:\n" + parseException.getMessage() );
        }
    }
}
